<?php
## include required files
/*******************************/
require_once '../../includefiles.php';
require_once '../../model/trade.php';
include_once("../../model/users.php");
/*******************************/
## Create Objects
/*******************************/
$objTrade = new Model_TRADE();
$userObj = new Model_Users();

if($_GET['jid']!='')
{	
		// get jobid id
		if($_GET['jid']!='')	
		{
			$explodestr= @explode(",",$_GET['jid']);
			for($i=0;$i<count($explodestr);$i++)
			{
				$newstrarray[$i]="'".$explodestr[$i]."'";
			} 
			$implodestr = @implode(",",$newstrarray);
			$jobtyppe_id = $implodestr;
			
		}
		if($jobtyppe_id!='')
			$regtradejobtypeArray = $objTrade->new_getAllJobtypeByTradeIdActiveStatus($jobtyppe_id);	
		else
			$regtradejobtypeArray = $objTrade->getAllJobTypeWithActiveStatus();
			
		if($_SESSION['getbids_id']!='')	
		{
			$userId = $_SESSION['getbids_id'];
			$userDetArray = $userObj->getUserDetailsByUserId($userId);
			
			for($i=0;$i<count($regtradejobtypeArray);$i++)
			{
				$exlodeArray_tradetype = @explode(",",$userDetArray['jobtype']);	
				if (@in_array($regtradejobtypeArray[$i]['id'], $exlodeArray_tradetype))
				{
					$regtradejobtypeArray[$i]['checked'] ='select';
				}
				else
				{
					$regtradejobtypeArray[$i]['checked'] ='notselect';	
				}
			}
			
		}
		//echo"<pre>";print_r($regtradejobtypeArray);die();
		$smarty->assign("regtradejobtypeArray", $regtradejobtypeArray);
}

if($_GET['jobidid']!='' || $_GET['jobtypeid']!='' || $_GET['find_jobidid']!='')
{	
		// get jobid id
		if($_GET['jid']!='')	
			$jobtyppe_id = $_GET['jid'];
			
		if($_GET['jobidid']!='')	
			$jobtyppe_id = $_GET['jobidid'];
			
		if($_GET['jobtypeid']!='')	
			$jobtyppe_id = $_GET['jobtypeid'];
			
		if($_GET['find_jobidid']!='')	
			$jobtyppe_id = $_GET['find_jobidid'];
			
		if($jobtyppe_id!='')
			$tradejobtypeArray = $objTrade->getAllJobtypeByTradeIdActiveStatus($jobtyppe_id);	
		else
			$tradejobtypeArray = $objTrade->getAllJobTypeWithActiveStatus();
		$smarty->assign("tradejobtypeArray", $tradejobtypeArray);
}

if($_GET['catid']!='')
{
	$tradejobtypeArray = $objTrade->getAllJobTypeWithActiveStatus();
	foreach($tradejobtypeArray as $tradejobtypeArray)
	{	
		$newarray[] =	$tradejobtypeArray['parent_id'];
	}
		
	$tradecategoryArray = array_values(array_unique($newarray));
	if($tradecategoryArray[0]!='')
	{
			$imopldeids = @implode(",",$tradecategoryArray);
			$newtradecatArray = $objTrade->getAllTradesCategoryWithmultipleId($imopldeids);
	}
	//echo "<pre>";print_R($tradecatArray);die();
	$smarty->assign("newtradecategoryArray", $newtradecatArray);
		
	$newtradejobtypeArray = $objTrade->getAllJobtypeByTradeIdActiveStatus($_GET['catid']);	
	$smarty->assign("newtradejobtypeArray", $newtradejobtypeArray);	
}


## Unset all the objects created which are on this page
unset($objCity);
	
$smarty->display(TEMPLATEDIR . '/modules/register/show_jobtype.tpl');
unset($smarty);
?>